﻿<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--开关主键-->
    <script src="/static/bootstrap/bootstrap-switch.js"></script>
    <link href="/static/bootstrap/bootstrap-switch.css" rel="stylesheet"/>

    <!--    配置select多选相关-->
    <script src="/static/layui/dist/xm-select.js"></script>

        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
</head>
<body>

<style>
    html, body{background-color: #fff!important;}
    .new_main{border-top:1px solid #ccc}
    .form-horizontal .form-group,.new_serach form{margin-bottom:0px;}
    .form-horizontal .control-label{padding: 0px;padding-top:7px;text-align: left;width: auto!important;}
    .batch{line-height:35px;}
</style>

<div class="newtest">

    <div class="container new_serach">

        <span> 姓名：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="name" value="{$name}" type="text">
        </div>
        <span> 标题：</span>
        <div class="layui-inline">
            <input class="form-control serach_key" name="keyword" value="{$keyword}" type="text">
        </div>
        <span> 回复状态：</span>
        <div class="layui-inline layui-form"  style="width:80px;">
            <select name="is_reply" lay-filter="is_reply">
                <option value="0" {if condition="$is_reply eq 0"} selected {/if}>全部</option>
                <option value="1" {if condition="$is_reply eq 1"} selected {/if}>未回复</option>
                <option value="2" {if condition="$is_reply eq 2"} selected {/if}>已回复</option>
            </select>
        </div>


        <input type="hidden" name="classify_id" value="{$classify_id}">
        <button class="layui-btn layui-btn-sm" data-type="reload">搜索</button>

    </div>

    <div class="new_main">
        <table class="layui-hide" id="demo" lay-filter="demo"></table>
        <script type="text/html" id="barDemo">
            <a class="btn-primary btn-sm" lay-event="detail">查看详情</a>
            <a class="btn-sm btn-danger" lay-event="del">删除</a>
        </script>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="getCheckLength">批量删除</button>
            </div>
        </script>

    </div>
</div>


</body>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<script>
    //全选操作

    var modal = new yii.modal();

    layui.use(['form', 'jquery', 'layer', 'laydate','table'], function () { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格
        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });
        var classify_id = $('input[name="classify_id"]').val();
        var is_reply = 0;
        form.on('select(is_reply)',function (data) {
            is_reply = data.value;
        });
        var url = "{:URL('community/message/index')}";
        //搜索操作
        $('.layui-btn').click(function () {
            var name = $('input[name="name"]').val();
            var keyword = $('input[name="keyword"]').val();
            var where = {keyword:keyword,is_reply:is_reply,name:name,classify_id:classify_id};
            search(table,url,where)
        });

        //列表
        var where = {type:'list',classify_id:classify_id};
        var title = "数据列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'id', title: 'ID',  sort: true, fixed: 'left',width:80, align:'center'}
            ,{field: 'name', title: '姓名', align:'center'}
            ,{field: 'mobile', title: '手机号', align:'center'}
            ,{field: 'title', title: '标题', align:'center'}
            ,{field: 'is_reply', title: '回复操作', align:'center'}
            ,{field: 'addtime', title: '添加时间', align:'center',sort: true}
            ,{fixed: 'right',title: '操作', width:300, align:'center', toolbar: '#barDemo'}
        ]];
        showlist(table,url,where,title,cols);

        //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'del':
                    layer.confirm('是否确定操作?', function (index) {
                        let url="{:URL('community/Message/delMessage')}";
                        let data = {id:id};
                        publicDel(table,url,data,obj,index);
                    });
                    break;
                case 'detail':
                    modal.initialization({
                        url: "{:URL('community/Message/detail')}",
                        type: "post",
                        data:{
                            id:id
                        }
                    });
                    break;
            }
        });

        //头工具栏事件
        table.on('toolbar(demo)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }
                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('community/Message/delMessage')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;

            };
        });



    });

</script>

</html>
